package com.lg.atp.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lg.atp.common.Constants;
import com.lg.atp.entity.TestTaskReport;
import com.lg.atp.service.IReportService;


@RestController
@RequestMapping("report")
public class ReportController {

	private static final Log log = LogFactory.getLog(ReportController.class);
	@Autowired
	private IReportService iReportService;
	
	
	@PostMapping("getTastRunReport")
	public Map<String,Object> selectTestTaskReport(){
		Map<String,Object> result = new HashMap<String,Object>();
		result.put("status", Constants.RETURN_SUCCESS);
		try {
			Map<String,List<TestTaskReport>> data = iReportService.selectRunReport();
			result.put("data", data);
		}catch(Exception e) {
			e.printStackTrace();
			log.error("获取任务执行状态报表失败："+e.getMessage());
			result.put("status", Constants.RETURN_FAIL);
			result.put("errorMsg", "获取任务执行状态报表失败");
		}
		return result;
	}
}
